home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / testylesample / testylesample.r < prev    next >
Encoding:
Text File  |  2000-09-28  |  8.9 KB  |  389 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware TextEdit Sample Application
  6. #
  7. #    TEStyleSample
  8. #
  9. #    TEStyleSample.r    -    Rez Source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                        10/89
  15. #
  16. #    Components:    TEStyleSample.p            October    1, 1989
  17. #                TEStyleSampleGlue.a        October    1, 1989
  18. #                TEStyleSample.r            October    1, 1989
  19. #                TEStyleSample.h            October    1, 1989
  20. #                PTEStyleSample.make        October    1, 1989
  21. #
  22. #    TEStyleSample is an example application that demonstrates how 
  23. #    to initialize the commonly used toolbox managers, operate 
  24. #    successfully under MultiFinder, handle desk accessories and 
  25. #    create, grow, and zoom windows. Both styled and fundamental TextEdit 
  26. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  27. #    also shows how to create and maintain scrollbar controls as well
  28. #    as implementing a basic printing loop.
  29. #
  30. #    It does not by any means demonstrate all the techniques you 
  31. #    need for a large application. In particular, TEStyleSample does not 
  32. #    cover exception handling, multiple windows/documents, 
  33. #    sophisticated memory management, or undo. All of 
  34. #    these are vital parts of a normal full-sized application.
  35. #
  36. #    This application is an example of the form of a Macintosh 
  37. #    application; it is NOT a template. It is NOT intended to be 
  38. #    used as a foundation for the next world-class, best-selling, 
  39. #    600K application. A stick figure drawing of the human body may 
  40. #    be a good example of the form for a painting, but that does not 
  41. #    mean it should be used as the basis for the next Mona Lisa.
  42. #
  43. #    We recommend that you review this program, TESample or Sample before 
  44. #    beginning a new application. TESample is a simpler version of TEStyleSample
  45. #    without styles and Sample is a simple app. which doesn’t 
  46. #    use TextEdit or the Control Manager.
  47. #
  48. ------------------------------------------------------------------------------*/
  49.  
  50. #include "SysTypes.r"
  51. #include "Types.r"
  52. #include "TEStyleSample.h"
  53.  
  54.  
  55.  
  56. resource 'vers' (1) {
  57.     0x01, 0x00, release, 0x00, verUS,
  58.     "1.00",
  59.     "1.00, Copyright © 1989 Apple Computer, Inc."
  60. };
  61.  
  62. /* we use an MBAR resource to conveniently load all the menus */
  63.  
  64. resource 'MBAR' (rMenuBar, preload) {
  65.     { mApple, mFile, mEdit, mFont, mFontSize, mStyle };        /* six menus */
  66. };
  67.  
  68.  
  69. resource 'MENU' (mApple, preload) {
  70.     mApple, textMenuProc,
  71.     AllItems & ~MenuItem2,    /* disable dashed line, enable About and DAs */
  72.     enabled, apple,
  73.     {
  74.         "About TEStyleSample…",
  75.             noicon, nokey, nomark, plain;
  76.         "-",
  77.             noicon, nokey, nomark, plain
  78.     }
  79. };
  80.  
  81. resource 'MENU' (mFile, preload) {
  82.     mFile, textMenuProc,
  83.     MenuItem12,                /* enable Quit only, program enables others */
  84.     enabled, "File",
  85.     {
  86.         "New",
  87.             noicon, "N", nomark, plain;
  88.         "Open",
  89.             noicon, "O", nomark, plain;
  90.         "-",
  91.             noicon, nokey, nomark, plain;
  92.         "Close",
  93.             noicon, "W", nomark, plain;
  94.         "Save",
  95.             noicon, "S", nomark, plain;
  96.         "Save As…",
  97.             noicon, nokey, nomark, plain;
  98.         "Revert",
  99.             noicon, nokey, nomark, plain;
  100.         "-",
  101.             noicon, nokey, nomark, plain;
  102.         "Page Setup…",
  103.             noicon, nokey, nomark, plain;
  104.         "Print…",
  105.             noicon, nokey, nomark, plain;
  106.         "-",
  107.             noicon, nokey, nomark, plain;
  108.         "Quit",
  109.             noicon, "Q", nomark, plain
  110.     }
  111. };
  112.  
  113. resource 'MENU' (mEdit, preload) {
  114.     mEdit, textMenuProc,
  115.     NoItems,                /* disable everything, program does the enabling */
  116.     enabled, "Edit",
  117.      {
  118.         "Undo",
  119.             noicon, "Z", nomark, plain;
  120.         "-",
  121.             noicon, nokey, nomark, plain;
  122.         "Cut",
  123.             noicon, "X", nomark, plain;
  124.         "Copy",
  125.             noicon, "C", nomark, plain;
  126.         "Paste",
  127.             noicon, "V", nomark, plain;
  128.         "Clear",
  129.             noicon, nokey, nomark, plain;
  130.         "-",
  131.             noicon, nokey, nomark, plain;
  132.         "Select All",
  133.             noicon, "A", nomark, plain
  134.     }
  135. };
  136.  
  137. /* Added for TEStyleSample */
  138. /* Font Menu */
  139. resource 'MENU' (mFont, preload) {
  140.     mFont, textMenuProc,
  141.     AllItems,                /* enable everything since these are fonts     */
  142.     enabled, "Font",
  143.      {
  144.      }
  145. };
  146.  
  147. /* Added for TEStyleSample */
  148. /* Size Menu Items */
  149. resource 'MENU' (mFontSize, preload) {
  150.     mFontSize, textMenuProc,
  151.     AllItems,                /* enable everything, since these are font sizes */
  152.     enabled, "Font Size",
  153.      {
  154.          "9 Point", noIcon, noKey, noMark, plain,
  155.         "10 Point", noIcon, noKey, noMark, plain,
  156.         "12 Point", noIcon, noKey, noMark, plain,
  157.         "14 Point", noIcon, noKey, noMark, plain,
  158.         "18 Point", noIcon, noKey, noMark, plain,
  159.         "24 Point", noIcon, noKey, noMark, plain
  160.      }
  161. };
  162.  
  163. /* Added for TEStyleSample */
  164. /* Style Menu Items */
  165. resource 'MENU' (mStyle, preload) {
  166.     mStyle, textMenuProc,
  167.     AllItems & ~MenuItem2,    /* enable everything except dash */
  168.     enabled, "Style",
  169.      {
  170.         "Plain",
  171.             noicon, "P", nomark, plain;
  172.         "-",
  173.             noicon, nokey, nomark, plain;
  174.         "Bold",
  175.             noicon, "B", nomark, bold;
  176.         "Italic",
  177.             noicon, "I", nomark, italic;
  178.         "Underline",
  179.             noicon, "U", nomark, underline;
  180.         "Outline",
  181.             noicon, nokey, nomark, outline;
  182.         "Shadow",
  183.             noicon, nokey, nomark, shadow
  184.     }
  185. };
  186.  
  187.  
  188. /* this ALRT and DITL are used as an About screen */
  189.  
  190. resource 'ALRT' (rAboutAlert, purgeable) {
  191.     {40, 20, 160, 296}, rAboutAlert, {
  192.         OK, visible, silent;
  193.         OK, visible, silent;
  194.         OK, visible, silent;
  195.         OK, visible, silent
  196.     };
  197. };
  198.  
  199. resource 'DITL' (rAboutAlert, purgeable) {
  200.     { /* array DITLarray: 5 elements */
  201.         /* [1] */
  202.         {88, 184, 108, 264},
  203.         Button {
  204.             enabled,
  205.             "OK"
  206.         },
  207.         /* [2] */
  208.         {8, 8, 24, 274},
  209.         StaticText {
  210.             disabled,
  211.             "Styled TextEdit Application"
  212.         },
  213.         /* [3] */
  214.         {32, 8, 48, 237},
  215.         StaticText {
  216.             disabled,
  217.             "Copyright © 1989 Apple Computer"
  218.         },
  219.         /* [4] */
  220.         {56, 8, 72, 136},
  221.         StaticText {
  222.             disabled,
  223.             "Brought to you by:"
  224.         },
  225.         /* [5] */
  226.         {80, 24, 112, 167},
  227.         StaticText {
  228.             disabled,
  229.             "Macintosh Developer Technical Support"
  230.         }
  231.     }
  232. };
  233.  
  234.  
  235. /* this ALRT and DITL are used as an error screen */
  236.  
  237. resource 'ALRT' (rUserAlert, purgeable) {
  238.     {40, 20, 150, 260},
  239.     rUserAlert,
  240.     { /* array: 4 elements */
  241.         /* [1] */
  242.         OK, visible, silent,
  243.         /* [2] */
  244.         OK, visible, silent,
  245.         /* [3] */
  246.         OK, visible, silent,
  247.         /* [4] */
  248.         OK, visible, silent
  249.     }
  250. };
  251.  
  252.  
  253. resource 'DITL' (rUserAlert, purgeable) {
  254.     { /* array DITLarray: 3 elements */
  255.         /* [1] */
  256.         {80, 150, 100, 230},
  257.         Button {
  258.             enabled,
  259.             "OK"
  260.         },
  261.         /* [2] */
  262.         {10, 60, 60, 230},
  263.         StaticText {
  264.             disabled,
  265.             "Error. ^0."
  266.         },
  267.         /* [3] */
  268.         {8, 8, 40, 40},
  269.         Icon {
  270.             disabled,
  271.             2
  272.         }
  273.     }
  274. };
  275.  
  276.  
  277. resource 'WIND' (rDocWindow, preload, purgeable) {
  278.     {64, 60, 314, 460},
  279.     zoomDocProc, invisible, goAway, 0x0, "untitled"
  280. };
  281.  
  282.  
  283. resource 'CNTL' (rVScroll, preload, purgeable) {
  284.     {-1, 385, 236, 401},
  285.     0, visible, 0, 0, scrollBarProc, 0, ""
  286. };
  287.  
  288.  
  289. resource 'CNTL' (rHScroll, preload, purgeable) {
  290.     {235, -1, 251, 386},
  291.     0, visible, 0, 0, scrollBarProc, 0, ""
  292. };
  293.  
  294. resource 'STR#' (kErrStrings, purgeable) {
  295.     {
  296.     "You must run on 512Ke or later";
  297.     "Application Memory Size is too small";
  298.     "Not enough memory to run TEStyleSample";
  299.     "Not enough memory to do Cut";
  300.     "Cannot do Cut";
  301.     "Cannot do Copy";
  302.     "Cannot exceed 32,000 characters with Paste";
  303.     "Not enough memory to do Paste";
  304.     "Cannot create window";
  305.     "Cannot exceed 32,000 characters";
  306.     "Cannot do Paste"
  307.     }
  308. };
  309.  
  310. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  311.  
  312. resource 'SIZE' (-1) {
  313.     dontSaveScreen,
  314.     acceptSuspendResumeEvents,
  315.     enableOptionSwitch,
  316.     canBackground,                /* we can background; we don't currently, but our sleep value */
  317.                                 /* guarantees we don't hog the Mac while we are in the background */
  318.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  319.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  320.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  321.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  322.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  323.     reserved,
  324.     reserved,
  325.     reserved,
  326.     reserved,
  327.     reserved,
  328.     reserved,
  329.     reserved,
  330.     kPrefSize * 1024,
  331.     kMinSize * 1024
  332. };
  333.  
  334.  
  335. type 'MOOT' as 'STR ';
  336.  
  337.  
  338. resource 'MOOT' (0) {
  339.     "Styled TextEdit Sample Application"
  340. };
  341.  
  342.  
  343. resource 'BNDL' (128) {
  344.     'MOOT',
  345.     0,
  346.     {
  347.         'ICN#',
  348.         {
  349.             0, 128
  350.         },
  351.         'FREF',
  352.         {
  353.             0, 128
  354.         }
  355.     }
  356. };
  357.  
  358.  
  359. resource 'FREF' (128) {
  360.     'APPL',
  361.     0,
  362.     ""
  363. };
  364.  
  365.  
  366. resource 'ICN#' (128) {
  367.     { /* array: 2 elements */
  368.         /* [1] */
  369.         $"04 30 40 00 0A 50 A0 00 0B 91 10 02 08 22 08 03"
  370.         $"12 24 04 05 20 28 02 09 40 10 01 11 80 0C 00 A1"
  371.         $"80 03 FF C2 7E 00 FF 04 01 00 7F 04 03 00 1E 08"
  372.         $"04 E0 00 0C 08 E0 00 0A 10 E0 00 09 08 C0 00 06"
  373.         $"04 87 FE 04 02 88 01 04 01 88 00 84 00 88 00 44"
  374.         $"00 88 00 44 00 88 00 C4 01 10 01 88 02 28 03 10"
  375.         $"01 C4 04 E0 00 02 08 00 73 BF FB EE 4C A2 8A 2A"
  376.         $"40 AA AA EA 52 AA AA 24 5E A2 8A EA 73 BE FB 8E",
  377.         /* [2] */
  378.         $"04 30 40 00 0E 70 E0 00 0F F1 F0 02 0F E3 F8 03"
  379.         $"1F E7 FC 07 3F EF FE 0F 7F FF FF 1F FF FF FF BF"
  380.         $"FF FF FF FE 7F FF FF FC 01 FF FF FC 03 FF FF F8"
  381.         $"07 FF FF FC 0F FF FF FE 1F FF FF FF 0F FF FF FE"
  382.         $"07 FF FF FC 03 FF FF FC 01 FF FF FC 00 FF FF FC"
  383.         $"00 FF FF FC 00 FF FF FC 01 FF FF F8 03 EF FF F0"
  384.         $"01 C7 FC E0 00 03 F8 00 73 BF FB EE 7F BE FB EE"
  385.         $"7F BE FB EE 7F BE FB E4 7F BE FB EE 73 BE FB 8E"
  386.     }
  387. };
  388.  
  389.